from django.db import models
from main.models import Course
from user.models import MyUser
# Create your models here.
class Collect(models.Model):
    user = models.ForeignKey(verbose_name="用户名",to=MyUser,on_delete=models.CASCADE)
    course = models.ForeignKey(verbose_name="课程名",to=Course,on_delete=models.CASCADE)
    def __str__(self):
        return f"{self.user}~~~收藏了~~~{self.course}"
    class Meta:
        verbose_name = "收藏课程"
        verbose_name_plural = "收藏课程"
        unique_together = ("user","course")



class Buy(models.Model):
    user = models.ForeignKey(verbose_name="用户名",to=MyUser,on_delete=models.CASCADE)
    course = models.ForeignKey(verbose_name="课程名",to=Course,on_delete=models.CASCADE)
    status = models.BooleanField(verbose_name="已支付",default=False)
    def __str__(self):
        return f"{self.user}！！！添加到购物车！！！{self.course}"
    class Meta:
        verbose_name = "课程订单"
        verbose_name_plural = "课程订单"
